<template>
  <div class="sales-chart" ref="salesChartRef"></div>
</template>

<script lang="ts">
export default {
  name: "SalesChart",
};
</script>

<script lang="ts" setup>
import * as echarts from "echarts";
import { onMounted, ref } from "vue";

const salesChartRef = ref();

onMounted(() => {
  const myEchart = echarts.init(salesChartRef.value);
  const option = {
    title: {
      text: "销售趋势",
      textStyle: {
        fontSize: 14,
      },
    },
    xAxis: {
      data: [
        "一月",
        "二月",
        "三月",
        "四月",
        "五月",
        "六月",
        "七月",
        "八月",
        "九月",
        "十月",
        "十一月",
        "十二月",
      ],
    },
    yAxis: {},
    series: {
      type: "bar",
      data: [25, 20, 29, 18, 23, 25, 20, 29, 18, 23, 30, 15],
      barWidth: 20,
    },
    tooltip: {},
    grid: {
      left: 0,
      right: 0,
      top: 40,
      bottom: 0,
      containLabel: true,
    },
  };
  myEchart.setOption(option);
});
</script>

<style scoped>
.sales-chart {
  width: 100%;
  height: 250px;
}
</style>
